﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAO;
using System.Data;
using DTO;
namespace BUS
{
    public class VeMayBayBUS
    {
        public DataTable layThongTinTinhPhi(string maVe)
        {
            VeMayBayDAO dao = new VeMayBayDAO();
            return dao.layThongTinTinhPhi(maVe);
        }
        public void HuyVe(string maVe, string maNhanVien,string soThe, float giaDoi, string ngayGhiPhieu)
        {
            VeMayBayDAO dao = new VeMayBayDAO();
            dao.HuyVe(maVe, maNhanVien,soThe, giaDoi, ngayGhiPhieu);
        }
        public bool kiemTraHuyVe(string maVe)
        {
            VeMayBayDAO dao = new VeMayBayDAO();
            return dao.kiemTraHuyVe(maVe);
        }
        public DataTable layThongTinVeBay(string maVe)
        {
             VeMayBayDAO dao = new VeMayBayDAO();
             return dao.layThongTinVeBay(maVe);
        }
        public bool kiemTraSoCho(string maVe, int loaiVe)
        {
            VeMayBayDAO dao = new VeMayBayDAO();
            DataTable dt = new DataTable();
            dt = dao.LaySoChoNgoi(maVe, loaiVe);
            if (dt.Rows.Count == 1)
            {
                if (int.Parse(dt.Rows[0]["soChoHienTai"].ToString()) <= 0)
                    return false;
                else
                    return true;
            }
            
               
            return false;
        }
        public DataTable tinhPhiNangHang(string maVe)
        {
            VeMayBayDAO dao = new VeMayBayDAO();
            return dao.tinhPhiNangHang(maVe);
        }
        public int NangHangVe(string maVe, int loaiVeCu, int loaiVeMoi, string maNhanVien, string maChuyenBay, float phi)
        {
             VeMayBayDAO dao = new VeMayBayDAO();
             return dao.NangHangVe(maVe, loaiVeCu, loaiVeMoi, maNhanVien, maChuyenBay, phi);
        }
        public DataTable tinhPhiChuyenDoiLichTrinh(string maVe)
        {
            VeMayBayDAO dao = new VeMayBayDAO();
            return dao.tinhPhiChuyenDoiLichTrinh(maVe);
        }
        public void chuyenDoiLichTrinh(string maVecu, int hangVeCu, string ChuyenBayCu, string maKhachHang,string maNhanVien, string maVeDi, string maChuyenBayDi, int hangVeDi, string maVeVe, string maChuyenVe, int hangVeVe, float phiDoiLichTrinh)
        {
            VeMayBayDAO dao = new VeMayBayDAO();
             dao.chuyenDoiLichTrinh(maVecu,hangVeCu,ChuyenBayCu,maKhachHang,maNhanVien,maVeDi,maChuyenBayDi,hangVeDi,maVeVe,maChuyenVe,hangVeVe,phiDoiLichTrinh);
        }
        public DataTable layDanhSachVe(string maChuyenBay)
        {
            VeMayBayDAO dao = new VeMayBayDAO();
            return dao.layDanhSachVe(maChuyenBay);
        }
        public int capNhatVeMayBay(string maVe, string viTri)
        {
            VeMayBayDAO dao = new VeMayBayDAO();
            return dao.capNhatVeMayBay(maVe, viTri);
        }
        public void datVe(KhachHangDTO kh, string maVeDi, string maChuyenBayDi, int hangVeDi, string maVeVe, string maChuyenVe, int hangVeVe, int doiTuong)
        {
            VeMayBayDAO dao = new VeMayBayDAO();

            dao.datVe(kh,maVeDi, maChuyenBayDi, hangVeDi, maVeVe, maChuyenVe, hangVeVe,doiTuong);
        }
        public DataTable layThongTinDatVeB3(string maChuyenMay, int hangVe)
        {
            VeMayBayDAO dao = new VeMayBayDAO();

            return dao.layThongTinDatVeB3(maChuyenMay, hangVe);
        }
       
    }
}
